package com.yixun.qfbao.response.premises;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.yixun.qfbao.model.dto.PremisesImageDto;
import com.yixun.qfbao.response.premises.detail.ApartmentInfo;
import com.yixun.qfbao.response.premises.detail.CaseMemberInfo;
import com.yixun.qfbao.response.premises.detail.CommisionInfo;
import com.yixun.qfbao.response.premises.detail.DetailInfo;
import com.yixun.qfbao.response.premises.detail.HeaderDisplayUrlInfo;
import com.yixun.qfbao.response.premises.detail.PremisesDynamicInfo;
import com.yixun.qfbao.response.premises.detail.PremisesFileInfo;
import com.yixun.qfbao.response.premises.detail.RewardInfo;
import com.yixun.qfbao.response.premises.detail.RuleInfo;
import com.yixun.qfbao.response.premises.detail.SellInfo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zilong.liu
 * @date 2020-8-11
 * 	详情查看返回的全部数据
 */
@Data
@Slf4j
public class PremisesDetailResDto implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "头部VR，视频链接")
	private HeaderDisplayUrlInfo headerDisplayUrlInfo;
	
	@ApiModelProperty(value = "头部详情信息，并包括点击查看的全部信息")
	private DetailInfo detailInfo;
	
	@ApiModelProperty(value = "案场人员信息")
	private CaseMemberInfo caseMemberInfo;
	
	@ApiModelProperty(value = "楼盘动态")
	private PremisesDynamicInfo premisesDynamicInfo;
	
	@ApiModelProperty(value = "佣金信息")
	private List<CommisionInfo> commisionInfos;
	
	@ApiModelProperty(value = "奖金信息")
	private RewardInfo rewardInfo;
	
	@ApiModelProperty(value = "规则信息")
	private RuleInfo ruleInfo;
	
	@ApiModelProperty(value = "卖点信息")
	private SellInfo sellInfo;
	
	@ApiModelProperty(value = "户型信息")
	private List<ApartmentInfo> apartmentInfos;
	
	@ApiModelProperty(value = "关注标识，具体描述可参考 AttetionStatusEnum")
	private int attetionFlag;
	
	@ApiModelProperty(value = "店铺收藏标识，具体描述可参考 AttetionStatusEnum")
	private int shopFlag;
	
	@ApiModelProperty(value = "报备方式，具体描述可参考ReportWayEnum")
	private String reportWay;
	
	@ApiModelProperty(value = "楼盘封面图URL")
	private String url;

	@ApiModelProperty(value = "最短时间(分钟)")
	private String specialTime;
	
	private List<PremisesFileInfo> premisesFileInfos;
	
	/**
	 * 添加户型信息
	 * @param apartmentInfo
	 */
	public void addApartmentInfo(ApartmentInfo apartmentInfo) {
		if(apartmentInfos == null) {
			apartmentInfos = new ArrayList<>();
		}
		apartmentInfos.add(apartmentInfo);
	}
	
	/**
	 * 添加户型信息
	 * @param apartmentInfo
	 */
	public void addPremisesFileInfos(Map<String,List<PremisesImageDto>> premisesImageDtos) {
		if(premisesImageDtos == null) {
			log.info("PremisesDetailResDto->addPremisesFileInfos->premisesImageDtos为空");
			return;
		}
		if(premisesFileInfos == null) {
			premisesFileInfos = new ArrayList<>();
		}
		String[] typeList = new String[] {"8", "9", "10", "11", "12", "13"};
		for (Entry<String, List<PremisesImageDto>> premisesImageDtoEntry : premisesImageDtos.entrySet()) {
			String type = premisesImageDtoEntry.getKey();
			boolean typeMatchFlag = false;
			for (String thisType : typeList) {
				if(thisType.equals(type)) {
					typeMatchFlag = true;
					break;
				}
			}
			if(!typeMatchFlag) {
				continue;
			}
			List<PremisesImageDto> premisesImageDtoList = premisesImageDtoEntry.getValue();
			for (PremisesImageDto premisesImageDto : premisesImageDtoList) {
				this.addPremisesFileInfo(new PremisesFileInfo(premisesImageDto));
			}
		}
	}
	
	/**
	 * 添加户型信息
	 * @param apartmentInfo
	 */
	public void addPremisesFileInfo(PremisesFileInfo premisesFileInfo) {
		if(premisesFileInfos == null) {
			premisesFileInfos = new ArrayList<>();
		}
		premisesFileInfos.add(premisesFileInfo);
	}
}
